home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / sep91.zip / 9N09024B < prev    next >
Text File  |  1991-07-12  |  612b  |  29 lines

  1.  
  2. /* --------------------------------------------------------------
  3.  
  4. FUNCTION GET_FREE_NODE: The steps to get a node from the free node list
  5. are:
  6.  
  7. A.  If the free node list is empty, get memory for a new node and 
  8. return its address.
  9.  
  10. B.  Else remove the first node from the free list and use that.
  11.  
  12. -------------------------------------------------------------- */
  13.  
  14. Node *get_free_node(void)
  15. {
  16.     Node *pnew_node;
  17.  
  18. /*A*/    if (pfree_node == NULL) {
  19.         pnew_node = malloc(sizeof(Node));
  20.     }
  21. /*B*/    else {
  22.         pnew_node = pfree_node;    
  23.         pfree_node = pfree_node->pfwd;    
  24.     }
  25.  
  26.     return pnew_node;
  27. }
  28.  
  29.